#include"comm.hpp"
#include"myfifo.hpp"
#include<unistd.h>
int main()
{
    key_t key = GetshmKeyOrDie();
    std::cout<<"key:"<<ToHex(key)<<std::endl;

    int shmid = Getshm(key,defaultsize);
    std::cout<<"shmid:"<<shmid<<std::endl;

    //挂接
    char *addr = (char *)shmAttach(shmid);
    std::cout<<"挂接成功,addr:"<<ToHex((uint64_t)addr)<<std::endl;

    memset(addr,0,defaultsize);

    Sync s;
    s.OpenWrite();

    while(1)
    {
        cin>>addr;
        sleep(1);
        s.Wakeup();
    }



    //去关联
    shmDetach(addr);
    std::cout<<"去关联成功,addr:"<<ToHex((uint64_t)addr)<<std::endl;
    return 0;
}